/* Copyright ©, 2022, ECARX (Hubei) Technology Co., Ltd. All rights reserved.
 *
 * NOTICE: This file contains information which is confidential and proprietary to ECARX
 * (Hubei) Technology Co., Ltd. and/or other developers. No license to any intellectual
 * property rights contained within this file is either granted or implied except as may be
 * provided in an agreement with ECARX (Hubei) Technology Co., Ltd.
 *
 * Any unauthorized copying or distribution of content from this file in whole or in part
 * is prohibited.
 */
#ifndef ECARX_VHAL_CORE_COMMON_H
#define ECARX_VHAL_CORE_COMMON_H

#include <VehicleUtils.h>
#include <android/hardware/automotive/vehicle/2.0/types.h>

#include "utils/convert.h"

using namespace ecarx::vhal::core::utils;
using namespace ::android::hardware::automotive::vehicle::V2_0;

using VehcilePropType = ::android::hardware::automotive::vehicle::V2_0::VehiclePropertyType;

/**
 * @brief Property Status
 * 
 */
enum class PropertyStatus : int32_t {
    /**
     * Property is available and behaving normally
     */
    Active = 0 /* 0x00 */,
    /**
     * A property in this state is not available for reading and writing.  This
     * is a transient state that depends on the availability of the underlying
     * implementation (e.g. hardware or driver). It MUST NOT be used to
     * represent features that this vehicle is always incapable of.  A get() of
     * a property in this state MAY return an undefined value, but MUST
     * correctly describe its status as UNAVAILABLE A set() of a property in
     * this state MAY return NOT_AVAILABLE. The HAL implementation MUST ignore
     * the value of the status field when writing a property value coming from
     * Android.
     */
    NotActive = 1 /* 0x01 */,
    /**
     * There is an error with this property.
     */
    Error = 2 /* 0x02 */,
    /**
     * Property is not config
     */
    NotAvailable = 3,
};

/// Mixed type define
using MixedValue = VehiclePropValue::RawValue;

/**
 * @brief persist mode
 * 
 */
enum class PersistType : int32_t {
    /// default mode ,No persistence
    Normal = 0,
    /// persist by DID
    DID = 1,
    /// persist by Profile
    Profile = 2,
    // persist by Preference
    Preference = 3,

};

struct RecordId {
    int32_t prop;
    int32_t area;

    bool operator==(const RecordId& other) const {
        return prop == other.prop && area == other.area;
    }
    bool operator<(const RecordId& other) const {
        return prop < other.prop || (prop == other.prop && area < other.area);
    }
};

enum class CommitMode{
  /// Commit when the committed value has Changed
  ValueChanged,
  /// Direct submission
  Direct
};

/**
 * @brief Enumeration to represent the different phases of work
 *
 */
enum class WorkPhase {
    /// This phase represents the initialization phase of work.
    INIT_PHASE,

    /// This phase represents the ready phase of work.
    READY_PHASE
};

#endif
